-- kill_up
-- created by xinj
-- 击杀敌人获得属性提升BUFF

return {
    apply = function(prop, baseValue)
        return baseValue + prop[3];
    end,

    -- 击杀触发
    trigger = function(who, prop, arg)
        if who.type ~= OBJECT_TYPE_USER then
            return;
        end

        local status = prop[2];

        -- 取当前已累加的属性
        local condition = CombatStatusM.queryCondition(who, status) or {};
        local value = condition["value"] or 0;

        -- 新的属性
        value = value + prop[3];

        local newCondition = {
            ["value"] = value,
            ["end_round"] = -1,
        }

        -- 更新状态
        CombatStatusM.applyStatus(who, status, newCondition);
    end,

    desc = function(prop)
        local row = PropM.getRow(prop[1]);
        local desc = row.desc;

        local key = prop[2];
        if key == "knight_power" or key == "devil_hug" or
           key == "archon" or key == "attack_improve" then
            -- 增加攻击的状态
            key = "attack";
        elseif key == "magic_improve" then
            key = "magic";
        end

        local attrib = FieldsM.getFieldName(key);
        if attrib then
            desc = string.gsub(desc, "{0}", attrib);
        end

        local v = prop[3];
        desc = string.gsub(desc, "{1}", v);

        return desc;
    end,

    record = function(target, prop, path)
        return false;
    end
};
